package org.study.dynamic.ds.strategy;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.study.dynamic.ds.constant.BusinessException;

import java.util.Map;

/**
 * 作用描述
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2023年06月08日
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class SqlParseStrategyContext {
    private final Map<String, SqlParseStrategy> sqlParseStrategyMap;

    public SqlParseStrategy getStrategy(String appDbType) {
        SqlParseStrategy sqlParseStrategy = this.sqlParseStrategyMap.get(appDbType);
        if (sqlParseStrategy == null) {
            throw new BusinessException("", "未找到" + appDbType + "的SQL解析策略");
        }
        return sqlParseStrategy;
    }
}
